<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en">
  <title id="fu141670">pg_aggregate</title>
  <body>
    <p>The <codeph>pg_aggregate</codeph> table stores information about aggregate functions. An
      aggregate function is a function that operates on a set of values (typically one column from
      each row that matches a query condition) and returns a single value computed from all these
      values. Typical aggregate functions are <codeph>sum</codeph>, <codeph>count</codeph>, and
        <codeph>max</codeph>. Each entry in <codeph>pg_aggregate</codeph> is an extension of an
      entry in <codeph>pg_proc</codeph>. The <codeph>pg_proc</codeph> entry carries the aggregate's
      name, input and output data types, and other information that is similar to ordinary
      functions.</p>
    <table id="fu141982">
      <title>pg_catalog.pg_aggregate</title>
      <tgroup cols="4">
        <colspec colnum="1" colname="col1" colwidth="131pt"/>
        <colspec colnum="2" colname="col2" colwidth="86pt"/>
        <colspec colnum="3" colname="col3" colwidth="85pt"/>
        <colspec colnum="4" colname="col4" colwidth="147pt"/>
        <thead>
          <row>
            <entry colname="col1">column</entry>
            <entry colname="col2">type</entry>
            <entry colname="col3">references</entry>
            <entry colname="col4">description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry colname="col1"><codeph>aggfnoid</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">OID of the aggregate function</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggkind</codeph></entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">Aggregate kind: <codeph>n</codeph> for <i>normal</i>
              aggregates, <codeph>o</codeph> for <i>ordered-set</i> aggregates, or
              <codeph>h</codeph> for <i>hypothetical-set</i> aggregates</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggnumdirectargs</codeph></entry>
            <entry colname="col2">int2</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">Number of direct (non-aggregated) arguments of an
              ordered-set or hypothetical-set aggregate, counting a variadic array as
              one argument. If equal to <codeph>pronargs</codeph>, the aggregate must be
              variadic and the variadic array describes the aggregated arguments as well
              as the final direct arguments. Always zero for normal aggregates.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggtransfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Transition function OID</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggfinalfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Final function OID (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggcombinefn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Combine function OID (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggserialfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">OID of the serialization function to convert
              transtype to <codeph>bytea</codeph> (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggdeserialfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">OID of the deserialization function to convert
              <codeph>bytea</codeph> to transtype (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggmtransfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Forward transition function OID for moving-aggregate mode
              (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggminvtransfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Inverse transition function OID for moving-aggregate mode
              (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggmfinalfn</codeph></entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Final function OID for moving-aggregate mode (zero if
              none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggfinalextra</codeph></entry>
            <entry colname="col2">bool</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">True to pass extra dummy arguments to
              <codeph>aggfinalfn</codeph></entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggmfinalextra</codeph></entry>
            <entry colname="col2">bool</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">True to pass extra dummy arguments to
              <codeph>aggmfinalfn</codeph></entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggsortop</codeph></entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_operator.oid</entry>
            <entry colname="col4">Associated sort operator OID (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggtranstype</codeph></entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">Data type of the aggregate function's internal transition (state)
              data</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggtransspace</codeph></entry>
            <entry colname="col2">int4</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">Approximate average size (in bytes) of the transition state
              data, or zero to use a default estimate</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggmtranstype</codeph></entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">Data type of the aggregate function's internal transition (state)
              data for moving-aggregate mode (zero if none)</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggmtransspace</codeph></entry>
            <entry colname="col2">int4</entry>
            <entry colname="col3"></entry>
            <entry colname="col4">Approximate average size (in bytes) of the transition state
              data for moving-aggregate mode, or zero to use a default estimate</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>agginitval</codeph></entry>
            <entry colname="col2">text</entry>
            <entry colname="col3"/>
            <entry colname="col4">The initial value of the transition state. This is a text field
              containing the initial value in its external string representation. If this field is
              NULL, the transition state value starts out NULL.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>aggminitval</codeph></entry>
            <entry colname="col2">text</entry>
            <entry colname="col3"/>
            <entry colname="col4">The initial value of the transition state for moving-
              aggregate mode. This is a text field containing the initial value in its
              external string representation. If this field is NULL, the transition state
              value starts out NULL.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </body>
</topic>
